/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package plagiadetector.driver;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Dell
 */
public class RegexDriver {
    public static void main(String[] args){
//        Pattern pat = Pattern.compile("\\(\\D*\\d{4}(;\\D*\\d{4})*\\)|\\[\\d*\\]");
//        Pattern pat = Pattern.compile("(\").+(\").*?\\(\\D*\\d{4}(;\\D*\\d{4})*\\)|\\[\\d*\\]");
        Pattern pat = Pattern.compile("(\")[^\"]+(\")[\\s]*?\\(\\D*\\d{4}(;\\D*\\d{4})*\\)|\\[\\d*\\]");
        
        String ujicoba = "\"let me \"count\" the ways.\" (Ricardo dkk., 2012) \" \"(Ricardo, 2012) \" \" (Ricardo, 2012) \" \" Ricardo (2012)";
        System.out.println(ujicoba.replaceAll("(\").+(\")\\(\\D*\\d{4}(;\\D*\\d{4})*\\)|\\[\\d*\\]", "aquila"));
        
        Matcher m = pat.matcher(ujicoba);
        ArrayList<String> hasil = new ArrayList<String>();
        
        while(m.find()){
            hasil.add(m.group());
        }
        
        
        System.out.println("String : "+ujicoba);
        for(String s : hasil){
            System.out.println("Match found : "+s);
        }
        
    }
}
